<?php

if (!defined('IN_XLP')) {
    exit('Access Denied!');
}
/*
  T('sms');
  $result = sms::send(13675823158, '您的验证码为' . getRandInt(6));
  if ($result) {
  echo $result;
  } else {
  print_r(sms::gerError());
  }
 */

/**
 * Description of sms
 * 短信发送
 * @author xlp
 */
class sms {

    public static $errInfo = null;
    public static $config = array();

    static public function init() {
        self::$config = array(
            'action'   => 'send',
            'account'  => 'AB00313',
            'password' => 'AB0031355',
        );
    }

    static public function send($phones, $content) {
        if (!$phones || !$content) {
            showError('号码或者短信内容不能为空');
        }
        self::init();
        self::$config['mobile'] = $phones;
        self::$config['content'] = $content;
        $queryArr = array();
        $rs = getHttp('https://dx.ipyy.net/smsJson.aspx', self::$config);
        $rs = json_decode($rs , true);
        if($rs['returnstatus'] == 'Success') {
            return true;
        }else{
            self::$errInfo = $rs['message'];
            return false;
        }
    }


    static public function gerError() {
        return self::$errInfo;
    }

}
